<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateShopOrderTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shop_order', function (Blueprint $table) {
            $table->increments('id');
            $table->integer("user_id")->default(0)->comment("用户ID");
            $table->string("order_sn",30)->default('')->comment("订单编号");
            $table->integer("coupon_id")->default(0)->comment("优惠券ID");
            $table->integer("coupon_type")->default(0)->comment("优惠券类型 参照优惠券表字段");
            $table->integer("coupon_amount")->default(0)->comment("优惠金额");
            $table->integer("order_amount")->default(0)->comment("订单金额(分)");
            $table->integer("free_amount")->default(0)->comment("运费");
            $table->integer("pay_amount")->default(0)->comment("实际支付金额");
            $table->string("pay_type",20)->default('')->comment("支付方式");
            $table->dateTime("pay_time")->default("0000-00-00 00:00:00")->comment("支付时间");
            $table->string("pay_sn",80)->default('')->comment("支付单号");
            $table->string("consignee",20)->default('')->comment("收货人姓名");
            $table->string("mobile",30)->default('')->comment("联系电话");
            $table->string("city_code",6)->default('')->comment("市代码");
            $table->string("city",30)->default('')->comment("市");
            $table->string("district_code",6)->default('')->comment("区代码");
            $table->string("district",30)->default('')->comment("区");
            $table->string("address",100)->default('')->comment("详细地址");
            $table->tinyInteger("order_status")->default(0)->comment("订单状态 1未支付 2已支付 3已发货 4确认收货 5已取消 6已退款 ");
            $table->tinyInteger("is_first")->default(0)->comment("是否是用户首单 0否 1是");
            $table->dateTime("shipping_time")->default("0000-00-00 00:00:00")->comment("发货时间");
            $table->dateTime("confirm_time")->default("0000-00-00 00:00:00")->comment("确认收货时间");
            $table->tinyInteger("is_oilcard")->default(0)->comment("是否油卡商品,0普通商品,1油卡商品");
            $table->tinyInteger("is_deleted")->default(0)->comment("是否删除 0否 1是");
            $table->dateTime("deleted_at")->default("0000-00-00 00:00:00")->comment("删除时间");
            $table->string("app_platform",15)->default('')->comment("应用平台ios or android or wechat");
            $table->string("app_channel",30)->default('')->comment("应用市场");
            $table->string("app_version",15)->default('')->comment("APP版本");
            $table->string("app_name",15)->default('')->comment("app name");
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('shop_order');
    }
}
